<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <title><!--{$lang.page.index.title}--></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="/static/lay/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/web/css/web.css" media="all">
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <form name="addItem" method="post" action="/web/menu/menusave" lay-filter="component-form-group" class="layui-form">
            <input type="hidden" value="<!--{$diInfo.id}-->" name="id">
            <div class="layui-form-item">
            	<div class="layui-inline">
                     <label class="layui-form-label"><!--{$lang.page.public.title}--></label>
                     <div class="layui-input-inline">
                     <input type="text" name="title" lay-verify="title" value="<!--{$diInfo.title}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input" />
                     </div>
                </div>
            </div>
            <div class="layui-form-item showfk">
              <label class="layui-form-label"><!--{$lang.page.public.langinfo}--></label>
              <div class="layui-inline" id="submue"  style="width:80%;">
                <table class="layui-table" id="sharetable" lay-filter="table">
                <thead>
                    <tr>
                        <td width='15%'><!--{$lang.page.public.lang}--></td>
                        <td width='20%'><!--{$lang.page.public.title}--></td>
                        <td width='10%'><a class="layui-btn layui-btn-xs addshare"><!--{$lang.page.public.add}--></a></td>
                    </tr>
                </thead>
                <tbody>
                    <!--{if empty($diInfo.titles)}-->
                    <tr>
                      <td>
                        <select name="langs[]">
                          <option value=""><!--{$lang.page.public.select}--></option>
                          <!--{foreach from=$langs.list item=item}-->
                          <option value="<!--{$item.value}-->"><!--{$item.name}--></option>
                          <!--{/foreach}-->
                        </select>
                      </td>
                      <td><input type="text" name="titles[]" value="" class="layui-input"></td>
                      <td><a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a></td>
                    </tr>
                     <!--{else}-->
                     <!--{foreach from=$diInfo.titles item=item key=key}-->
                    <tr>
                      <td>
                        <select name="langs[]">
                          <option value=""><!--{$lang.page.public.select}--></option>
                          <!--{foreach from=$langs.list item=items}-->
                          <option value="<!--{$items.value}-->" <!--{if $key eq $items.value}-->selected<!--{/if}-->><!--{$items.name}--></option>
                          <!--{/foreach}-->
                        </select>
                      </td>
                      <td><input type="text" name="titles[]" value="<!--{$item}-->" class="layui-input"></td>
                      <td><a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a></td>
                    </tr>
                     <!--{/foreach}-->
                     <!--{/if}-->
                  </tbody>
                </table>
              </div>

            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                  <label class="layui-form-label"><!--{$lang.page.public.higher}--></label>
                  <div class="layui-input-inline" >
                    <select name="pid" id="smallname" >
                      <option value="0"><!--{$lang.page.table.higtestmue}--></option>
                      <!--{foreach item=item from=$pmenu}-->
                      <option value="<!--{$item.id}-->" <!--{if $item.id eq $diInfo.pid}-->selected<!--{/if}-->><!--{$item.title}--></option>
                      <!--{/foreach}-->
                     </select>
                  </div>
                </div>

                <div class="layui-inline">
                  <label class="layui-form-label"><!--{$lang.page.table.sort}--></label>
                  <div class="layui-input-inline" style="width:50%">
                    <input type="text" name="orderid"  lay-verify="orderid"  value="<!--{$diInfo.orderid}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                  </div>
                </div> 
            </div>

            <div class="layui-form-item" id="appointdiv" <!--{if !$diInfo.is_icon}-->style="display:none;"<!--{/if}--> >
              <label class="layui-form-label"><!--{$lang.page.public.icon}--></label>

                <div class="layui-inline">
                <div class="layui-upload">
                  <blockquote class="viewpicList">
                  <ul>
                      <li class="viewpic" id="picdemo" <!--{if empty($diInfo.icon)}-->style="display:none;"<!--{/if}-->><img id="demo" src="<!--{$diInfo.icon}-->" /></li>
                      <button type="button" class="picup" id="icon">+</button>
                  </ul>
                  </blockquote>
                </div>
                 <span>（<!--{$lang.page.public.suggest}-->1:1<!--{$lang.page.public.dimensions}-->）</span>
                 <input id="imgOne" name="imgOne" type="hidden"/>
                </div>

            </div>

            <div class="layui-form-item">
              <div class="layui-inline">
                 <label class="layui-form-label">icon</label>
                 <div class="layui-input-block">
                  <input type="radio" name="is_icon" value="0" title="否" lay-filter="brickType" <!--{if $diInfo.is_icon eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="is_icon" value="1" title="是" lay-filter="brickType" <!--{if $diInfo.is_icon eq 1}--> checked<!--{/if}-->>
                 </div>
               </div>
              <div class="layui-inline">
                  <label class="layui-form-label"><!--{$lang.page.table.ident}--></label>
                  <div class="layui-input-block">
                    <input type="text" name="acode"  value="<!--{$diInfo.acode}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
                  </div>
              </div>
            </div>

            

            <div class="layui-form-item">

              <div class="layui-inline">
                 <label class="layui-form-label"><!--{$lang.page.table.openpage}--></label>
                 <div class="layui-input-block">
                 <input type="radio" name="is_target" value="0" title="<!--{$lang.page.table.no}-->" <!--{if $diInfo.is_target eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="is_target" value="1" title="<!--{$lang.page.table.yes}-->" <!--{if $diInfo.is_target eq 1}--> checked<!--{/if}-->>
                </div>
              </div>

            <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.table.rightmue}--></label>
            <div class="layui-input-block">
              <input type="radio" name="special" value="0" title="<!--{$lang.page.table.no}-->" <!--{if $diInfo.special eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="special" value="1" title="<!--{$lang.page.table.yes}-->" <!--{if $diInfo.special eq 1}--> checked<!--{/if}-->>
            </div>
            </div>
          
            <div class="layui-inline">
            <label class="layui-form-label"><!--{$lang.page.table.status}--></label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="0" title="<!--{$lang.page.table.close}-->" <!--{if $diInfo.status eq 0}--> checked<!--{/if}-->  >&nbsp;&nbsp;<input type="radio" name="status" value="1" title="<!--{$lang.page.table.normal}-->" <!--{if $diInfo.status eq 1}--> checked<!--{/if}-->>
            </div>
          </div>
        </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label"><!--{$lang.page.table.entryurl}--></label>
            <div class="layui-input-inline" style="width:50%">
              <input type="text" name="url"  lay-verify="url"  value="<!--{$diInfo.url}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.table.page}--> <!--{$lang.page.table.code}--></label>
              <div class="layui-input-inline">
                <input type="text" name="pagecode"  lay-verify="pagecode"  value="<!--{$diInfo.pagecode}-->" placeholder="<!--{$lang.page.public.pinput}-->" autocomplete="off" class="layui-input">
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label"><!--{$lang.page.public.parameter}--></label>
              <div class="layui-input-inline">
                <input type="text" name="param"  lay-verify="param"  value="<!--{$diInfo.param}-->" placeholder="<!--{$lang.page.public.pinput}-->; key:value,key:value" autocomplete="off" class="layui-input">
              </div>
            </div>
          </div>    
                  
          <div class="layui-form-item layui-layout-admin">
            <div>
              <div class="layui-footer" style="left: 0;">
                 <button class="layui-btn" type="button" id="submit" lay-submit lay-filter="submit"><!--{$lang.page.public.submit}--></button>
                <button type="reset" class="layui-btn layui-btn-primary"><!--{$lang.page.public.reset}--></button>
                <button type="button" class="layui-btn layui-btn-primary" onClick="xadmin.close();" ><!--{$lang.page.table.back}--></button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>

</body>
</html>
  <script src="/static/lay/layui/layui.js"></script>
  <script type="text/javascript">
    layui.config({
     base: '/static/lay/' //静态资源所在路径
   }).extend({
     xadmin: 'lib/xadmin' //弹窗
   }).use(['jquery', 'layer','xadmin', 'form'], function(){
    var form = layui.form;
     form.render(null, 'component-form-group');
     /* 自定义验证规则 */
    form.verify({

      title: function(value){
        if(value.length < 1){
          return '<!--{$lang.page.table.name}--> <!--{$lang.page.public.nocontent}-->';
        }
      }
      ,orderid:function(value){
        if(value.length < 1){
          return '<!--{$lang.page.table.sort}--> <!--{$lang.page.public.nocontent}-->';
        }
        if(!(/^[0-9]*$/).test(value)){
           return '<!--{$lang.page.table.sort}--> <!--{$lang.page.public.paraerror}-->';
        }
      } 
      ,url: function(value){
        if(value.length < 1){
          return '<!--{$lang.page.table.addr}--> <!--{$lang.page.public.nocontent}-->';
        }
      }

    });

    //动态添加表单
    //因为动态添加的元素class属性是无效的，所以不能用
    $('body').on('click', '.addshare', function() {
      if ($('#sharetable tbody tr').length > <!--{$langs.total-1}-->) {
        layer.msg('<!--{$lang.page.public.moreset}--> <!--{$langs.total}--> <!--{$lang.page.public.strip}-->', {
            offset: '20px', 
            time : 2000
        });
      }else{
      //添加html
        var html = '<tr>'+
          '<td><select name="langs[]"><option value=""><!--{$lang.page.public.select}--></option>'+
          <!--{foreach from=$langs.list item=item}-->
          '<option value="<!--{$item.value}-->"><!--{$item.name}--></option>'+
          <!--{/foreach}-->
          '</select></td>'+
          '<td><input type="text" name="titles[]" value="" class="layui-input"></td>'+
          '<td>'+'<a class="layui-btn layui-btn-danger layui-btn-xs delshare"><!--{$lang.page.public.del}--></a>'+
          '</td>'+
          '</tr>';
        //添加到表格最后
        $(html).appendTo($('#sharetable tbody:last'));
        form.render();
      }
    });
    $('body').on('click', '.delshare', function() {
      if ($('#sharetable tbody tr').length === 1) {
        layer.msg('<!--{$lang.page.public.onenodel}-->', {
            time : 2000
        });
      } else {
        //删除当前按钮所在的tr
        $(this).closest('tr').remove();
      }
    });

    form.on('radio(brickType)', function(data){
        var p = data.value;
        if(p > 0){
        $('#appointdiv').show();
        }else{
        $('#appointdiv').hide();
        }
        form.render();
      });

    form.on('submit(submit)', function (data) {
          $('#submit').attr("disabled",true);
          $('#submit').addClass('layui-btn-disabled');
                $.post('#',data.field,function(res){
                    if(res.code == 200){
                        layer.msg(res.msg);
                        setTimeout(() => {
                          window.parent.location.reload();
                          xadmin.close();
                        }, 1000);
                    }else{
                        layer.msg(res.msg);
                    }
                })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

  });

       //上传图片
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //图片上传
        var uploadInst = upload.render({
            elem: '#icon'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                  $('#demo').attr('src', result); //图片链接（base64）
                  $('#img').attr('value', '1'); //确定数据填写
                  $('#imgOne').attr('value', result); //图片链接（base64)
                  $('#picdemo').show();
                });
            }
        });

    });

  </script>